﻿#include "widget.h"
#include <QApplication>
#include <QTimer>
#include <QFileInfo>
#ifdef Q_OS_WIN
#include <Windows.h>
#endif // QS_WIN



void myDebugOutput(QtMsgType type, const QMessageLogContext& context, const QString& msg) {
	const char* func = context.function ? context.function : "unknow";
	std::string _msg = msg.toStdString();
	QFileInfo fileInfo(context.file);
	QString fileName = fileInfo.fileName();
	QString output = QString("[%1:%2] %3\r\n")
		.arg(fileName)
		.arg(context.line).arg(msg);
#ifdef Q_OS_WIN
	OutputDebugString(output.toStdWString().c_str());
#endif // QS_WIN
}

int main(int argc, char* argv[])
{
	QApplication a(argc, argv);
#ifdef Q_OS_WIN
	qInstallMessageHandler(myDebugOutput);
#endif // QS_WIN
	Widget w;
	w.show();
	QTimer::singleShot(50, [&w] {
		w.init();
		});
	return a.exec();
}
